package com.rags.chess.game;

import java.util.Vector;

import com.rags.chess.base.Color;
import com.rags.chess.base.Coordinate;
import com.rags.chess.base.PieceType;
import com.rags.chess.move.Move;
import com.rags.chess.move.Resign;

public class PlayerStub implements Player {
	private Color color;
	private String name;
	private Vector<Coordinate> start = new Vector<Coordinate>();
	private Vector<Coordinate> end = new Vector<Coordinate>();
	private int moveCount = 0;
	
	public PlayerStub(Color c, String n, String[] startSquares, String[] endSquares) {
		color = c;
		name = n;
		for (int i=0; startSquares != null && i<startSquares.length; i++) {
			start.add(new Coordinate(startSquares[i]));
			end.add(new Coordinate(endSquares[i]));
		}
	}
	
	public Color getColor() {
		return color;
	}
	
	public PieceType returnPawnPromotionPiece() {
		return PieceType.Queen;
	}

	public Move makeMove(Game g) {
		if (start == null || end == null || start.size() <= moveCount || end.size() <= moveCount)
			return new Resign(g);
		
		Move move = g.createMove(this, start.elementAt(moveCount), end.elementAt(moveCount));
		moveCount++;
		move.makeMove();
		return move;
	}

	public int getMoveCount() {
		return moveCount;
	}

	public String getName() {
		return name;
	}
}
